<%-- 
    Document   : addCdAction
    Created on : Feb 25, 2012, 3:30:45 AM
    Author     : Hiroroi
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="java.sql.*, DBConnection.*, UserPackage.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            String cdArtist, cdAlbum, cdDate, synopsis, price;
            boolean result;
            int cdTrack;
            
            cdArtist = request.getParameter("cdArtist");
            cdAlbum = request.getParameter("cdAlbum");
            cdDate = request.getParameter("cdDate");
            cdTrack = Integer.parseInt(request.getParameter("cdTrack"));
            synopsis = request.getParameter("synopsis");
            price = request.getParameter("price");
            
           /* cdArtist = cdArtist.replaceAll("[^a-zA-Z0-9@._]", "");
            cdAlbum = cdAlbum.replaceAll("[^a-zA-Z0-9@._]", "");
            cdDate = cdDate.replaceAll("[^a-zA-Z0-9@._]-", "");*/
            inputChecker check = new inputChecker();
            if(check.stringCompare(cdArtist) && check.stringCompare(cdAlbum) && check.dateCheck(cdDate)){
            Product newBook = new Product();
            
            Product newCd = new Product();
            
            newCd.setCdArtist(cdArtist);
            newCd.setCdAlbum(cdAlbum);
            newCd.setCdDate(cdDate);
            newCd.setCdTrackNo(cdTrack);
            newCd.setSynopsis(synopsis);
            newCd.setPrice(price);
            
            result = new ProductManager().addCd(newCd);
            
            if(result == true)
                response.sendRedirect("addCd.jsp");
                       }
            else
                response.sendRedirect("prodMgrHomePage.jsp");
          %>
    </body>
</html>
